package com.onlyphoto.onlymall.mvp.model

import com.onlyphoto.onlymall.api.Urls
import com.onlyphoto.onlymall.base.BaseEntity
import com.onlyphoto.onlymall.base.BaseModel
import com.onlyphoto.onlymall.base.BaseObserver
import com.onlyphoto.onlymall.bean.request.RefundBean
import com.onlyphoto.onlymall.bean.response.RefundInfoBean
import com.onlyphoto.onlymall.bean.response.RefundReasonBean
import com.onlyphoto.onlymall.utils.ConfigUtil
import com.onlyphoto.onlymall.utils.RxTransformer


class MRefundImpl : BaseModel() {

    var url = ""
    fun refund(bean: RefundBean, baseObserver: BaseObserver<BaseEntity>) {
        url = ConfigUtil.instance.getUrl(Urls.GOODS_ORDER)
        apiService().refund(url, bean)
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }

    fun getRefundReason(baseObserver: BaseObserver<ArrayList<RefundReasonBean>>) {
        url = ConfigUtil.instance.getUrl(Urls.REFUND_REASON_TYPE)
        apiService().getRefundReason(url)
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }

    fun getRefundInfo(getType: Int, orderId: String, baseObserver: BaseObserver<RefundInfoBean>) {
        url = ConfigUtil.instance.getUrl(Urls.GOODS_ORDER)
        apiService().getRefundInfo(url, getType, orderId)
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }
}

